﻿using System;
using System.Drawing;

namespace delegatedemo5
{
    class Program
    {
        static void Main(string[] args)
        {
            Point[] points = { new Point(100, 300), new Point(150, 250), new Point(250, 400), new Point(275, 405), new Point(300, 450) };

            Predicate<Point> predicate = FindPoints;
            Point first = Array.Find(points, predicate);

            Console.WriteLine("Found: X = {0}, Y = {1}", first.X, first.Y);

            predicate = (Point x) => x.X * x.Y == 30000;
            first = Array.Find(points, predicate);
            Console.WriteLine("Found: X = {0}, Y = {1}", first.X, first.Y);

            Predicate<Point> predicate2 = FindPoints;
            Point[] all = Array.FindAll(points, predicate2);
            foreach(Point point in all)
            {
                Console.WriteLine("Found: X = {0}, Y = {1}", point.X, point.Y);
            }
        }

        private static bool FindPoints(Point obj)
        {
            return obj.X * obj.Y > 100000;
        }
    }
}